package biz

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
)

type User struct {
	Id    int64
	Age   int32
	Name  string
	Email string
}

// UserRepo 定义数据仓库接口
type UserRepo interface {
	CreateUser(ctx context.Context, req *User) (*User, error)
	ListUser(ctx context.Context, req *User) ([]*User, error)
}

// UserUsecase 定义业务逻辑
type UserUsecase struct {
	repo UserRepo
	log  *log.Helper
}

// NewUsecase 创建Usecase
func NewUserUsecase(repo UserRepo, logger log.Logger) *UserUsecase {
	return &UserUsecase{repo: repo, log: log.NewHelper(logger)}
}

// CreateUser 创建用户
func (uc *UserUsecase) CreateUser(ctx context.Context, req *User) (*User, error) {
	return uc.repo.CreateUser(ctx, req)
}

// ListUser 获取用户列表
func (uc *UserUsecase) ListUser(ctx context.Context, req *User) ([]*User, error) {
	return uc.repo.ListUser(ctx, req)
}
